Antipattern: Make SQL a Second-Class Citizen
Let's discuss the reasons for which databases may be assumed to be exempt from the best practices.
Even among developers who follow the best practices when developing application code, there’s a tendency to think of database code as exempt from these practices. Let’s call this antipattern Diplomatic Immunity because it assumes that the rules of application development don’t apply to database development.
The reasons for not following the best practices#
Why do developers assume it to be acceptable to not follow the best practices when developing a database?
The following are some possible reasons:
-
Separate roles of software engineers and database administrators
-
Language variations
-
Unseasoned database developments
-
Focused on DBA only
Role of a software engineer and a database administrator#
The roles of a software engineer and database administrator are separate in some companies. The DBA typically works with several teams of programmers, so they’re often not considered a full-time member of any one of those teams. They’re treated like a visitor and are not subject to the same responsibilities as the software engineers.
Language variations#
The SQL language used for relational databases differs from conventional programming. Even the way we invoke SQL statements as a specialized language within application code suggests that it enjoys some kind of a guest-like status.
Unseasoned database developments#
Advanced IDE tools are famous for application code languages, making editing, testing, and source control quick and painless. But tools for database development are not as advanced, or at least not as widely used. Developers can code applications with best practices easily, but applying these practices to SQL feels clumsy by comparison. Developers tend to find other things to do.
Focused on DBA only#
In IT, it’s ordinary for knowledge and operation of the database to be with one person — the DBA. Because the DBA is the only one who has access to the database server, they serve as a living knowledge base and source control system.
The database is the foundation of an application and quality matters. It’s not infrequent that a developer knows how to develop high-quality application code, but ends up building their application on top of a database that has failed to solve the project’s needs or one that no one understands. The risk lies in that we’re developing an application only to find that we have to scrap it.